
import requests
from util.time_stamp import get_time_stamp
import execjs
import hashlib

with open(f'./parse/2.福建公共信息交易平台.js', 'r', encoding='utf-8') as f:
    js_str = f.read()
    js_code = execjs.compile(js_str)


page = 1

e = {
    "ts": get_time_stamp(),
    "pageNo": page,
    "pageSize": 20,
    "type": "12",
    "IS_IMPORT": 1,
    "total": 3408,
    "KIND": "GCJS",
    "GGTYPE": "1",
    "timeType": "6",
    "BeginTime": "2025-05-20 00:00:00",
    "EndTime": "2025-11-20 23:59:59",
}

n = js_code.call('d', e)
sign = hashlib.md5(n.encode()).hexdigest()
print(sign)

e.update({
    "AREACODE": "",
    "M_PROJECT_TYPE": "",
    "PROTYPE": "",
    "createTime": "",
})

res = requests.post('https://ggzyfw.fj.gov.cn/FwPortalApi/Trade/TradeInfo',json=e,headers={
    'portal-sign':sign,
})

# print(res,res.json()['Data'])

r = js_code.call('b', res.json()['Data'])
print(r)